home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / gnuwget.zip / wget-1.4.3 / src / ftp.h < prev    next >
C/C++ Source or Header  |  1997-01-23  |  3KB  |  93 lines

  1. /* Declarations for FTP support.
  2.    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
  3.    
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2 of the License, or
  7.    (at your option) any later version.
  8.    
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.    
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18.  
  19. #ifndef FTP_H
  20. #define FTP_H
  21.  
  22. /* You can change this to something else, like "ftp", but I suggest
  23.    "anonymous". */
  24. #define DEFAULT_FTP_ACCT "anonymous"
  25.  
  26. /* File where the "ls -al" listing will be saved. */
  27. #define LIST_FILENAME ".listing"
  28.  
  29. /* File types. */
  30. enum ftype {
  31.    PLAINFILE = 0,
  32.    DIRECTORY,
  33.    SYMLINK,
  34.    UNKNOWN
  35. };
  36.  
  37. /* Globbing (used by ftp_retrieve_glob). */
  38. enum {
  39.    GLOBALL, GETALL, GETONE
  40. };
  41.  
  42. /* Information about one filename in a linked list. */
  43. struct fileinfo {
  44.    enum ftype type;             /* File type */
  45.    char *name;                  /* File name */
  46.    long size;                   /* File size */
  47.    long tstamp;                 /* Time-stamp */
  48.    int perms;                   /* File permissions */
  49.    char *linkto;                /* Link to which file points */
  50.    struct fileinfo *prev;       /* Previous... */
  51.    struct fileinfo *next;       /* ...and next structure. */
  52. };
  53.  
  54. /* Commands for FTP functions. */
  55. enum command {
  56.    DO_LOGIN      = 0x0001,      /* Connect and login to the server. */
  57.    DO_CWD        = 0x0002,      /* Change current directory. */
  58.    DO_RETR       = 0x0004,      /* Retrieve the file. */
  59.    DO_LIST       = 0x0008,      /* Retrieve the directory list. */
  60.    LEAVE_PENDING = 0x0010       /* Do not close the socket. */
  61. };
  62.  
  63. enum fstatus {
  64.    NOTHING       = 0x0000,      /* Nothing done yet. */
  65.    ON_YOUR_OWN   = 0x0001,      /* The ftp_loop_internal sets the
  66.                                    defaults. */
  67.    DONE_CWD      = 0x0002       /* The current working directory is
  68.                                    correct. */
  69. };
  70.  
  71. typedef struct {
  72.    int st;                      /* Connection status. */
  73.    int cmd;                     /* Command code. */
  74.    int fd;                      /* Control connection fd. */
  75.    long dltime;                 /* Time of the download. */
  76. } ccon;
  77.  
  78. uerr_t getftp PARAMS((const urlinfo *, long *, long, ccon *));
  79. uerr_t ftp_loop_internal PARAMS((urlinfo *, struct fileinfo *, ccon *));
  80. struct fileinfo *ftp_get_listing PARAMS((urlinfo *, ccon *));
  81. struct fileinfo *ftp_parse_ls PARAMS((const char *));
  82. uerr_t ftp_retrieve_list PARAMS((urlinfo *, struct fileinfo *, ccon *));
  83. uerr_t ftp_retrieve_glob PARAMS((urlinfo *, ccon *, int));
  84. uerr_t ftp_retrieve_dirs PARAMS((urlinfo *, struct fileinfo *, ccon *));
  85. uerr_t ftp_loop PARAMS((urlinfo *, int *));
  86.  
  87. int symperms PARAMS((const char *));
  88. struct fileinfo *ftp_parse_unix_ls PARAMS((const char *));
  89. void freefileinfo PARAMS((struct fileinfo *));
  90. struct fileinfo *delelement PARAMS((struct fileinfo *, struct fileinfo **));
  91.  
  92. #endif /* FTP_H */
  93.